package com.ruoyi.tsjData.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.tsjData.domain.result.DataTshjResultDetail;
import com.ruoyi.tsjData.service.IDataTshjResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 提升机结果Controller
 * 
 * @author ruoyi
 * @date 2023-11-22
 */
@RestController
@RequestMapping("/tshjResult/all")
public class DataTshjResultController extends BaseController
{
    @Autowired
    private IDataTshjResultService dataTshjResultService;

    /**
     * 查询提升机结果列表
     */
    @PreAuthorize("@ss.hasPermi('tshj:result:list')")
    @GetMapping("/list")
    public AjaxResult list(DataTshjResultDetail dataTshjResult)
    {
        List<DataTshjResultDetail> list = dataTshjResultService.selectDataTshjResultList(dataTshjResult);
        return success(list);
    }

    /**
     * 导出提升机结果列表
     */
    @PreAuthorize("@ss.hasPermi('tshj:result:export')")
    @Log(title = "提升机结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataTshjResultDetail dataTshjResult)
    {
        List<DataTshjResultDetail> list = dataTshjResultService.selectDataTshjResultList(dataTshjResult);
        ExcelUtil<DataTshjResultDetail> util = new ExcelUtil<>(DataTshjResultDetail.class);
        util.exportExcel(response, list, "提升机结果数据");
    }

    /**
     * 获取提升机结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('tshj:result:query')")
    @GetMapping(value = "/{resultId}")
    public AjaxResult getInfo(@PathVariable("resultId") Long resultId)
    {
        return success(dataTshjResultService.selectDataTshjResultByResultId(resultId));
    }

    /**
     * 新增提升机结果
     */
    @PreAuthorize("@ss.hasPermi('tshj:result:add')")
    @Log(title = "提升机结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataTshjResultDetail dataTshjResult)
    {
        return toAjax(dataTshjResultService.insertDataTshjResult(dataTshjResult));
    }

    /**
     * 修改提升机结果
     */
    @PreAuthorize("@ss.hasPermi('tshj:result:edit')")
    @Log(title = "提升机结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataTshjResultDetail dataTshjResult)
    {
        return toAjax(dataTshjResultService.updateDataTshjResult(dataTshjResult));
    }

    /**
     * 删除提升机结果
     */
    @PreAuthorize("@ss.hasPermi('tshj:result:remove')")
    @Log(title = "提升机结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{resultIds}")
    public AjaxResult remove(@PathVariable Long[] resultIds)
    {
        return toAjax(dataTshjResultService.deleteDataTshjResultByResultIds(resultIds));
    }
}
